window.onload = function() {
    var regtel = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
    var regpwd = /^[a-zA-Z]\w{5,17}$/;
    var tel = document.querySelector('#tel');
    var pwd = document.querySelector('#pwd');
    var tx = document.querySelector('#login-tx')
    var dlbtn = document.querySelector('.login-dlbtn');
    var eye = document.querySelector('#eye')



    tel.onfocus = function() {
        if (this.value === '请输入手机号码') {
            this.value = '';
        }
        this.style.color = '#333'
    };
    tel.onblur = function() {
        if (this.value === '') {
            this.value = '请输入手机号码';
        }
        this.style.color = '#ccc';
    }

    // regexp(pwd, regpwd);

    //表单验证的函数

    tel.onblur = function() {
        if (regtel.test(this.value)) {
            this.nextElementSibling.className = 'success';
            dlbtn.classList.add('pass')

        } else {
            this.nextElementSibling.className = 'error';
            // dlbtn.classList.remove('pass')
            // tx.style.display = 'block';

        }
    }
    // pwd.onblur = function() {
    //     if (regpwd.test(this.value)) {
    //         tx.style.display = 'none';
    //     } else {
    //         tx.style.display = 'block';
    //         this.value = '';
    //     }
    // }
    tx.onclick = function() {
        this.style.display = 'none'
    }


    var flag = 0;
    eye.onclick = function() {
        if (flag == 0) {
            pwd.type = 'text';
            eye.src = './img/zhengyan.png';
            flag = 1;
        } else {
            pwd.type = 'password';
            eye.src = './img/biyan.png';
            flag = 0;
        }
    }

}